

<%@ page import="com.surelution.tinyerp.FeeList" %>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
        <meta name="layout" content="main" />
        <g:set var="entityName" value="${message(code: 'feeList.label', default: 'FeeList')}" />
        <g:javascript library="jquery"/>
        
        <script type="text/javascript">
			function loadFeeType() {
				$('#feeType\\.id').find("option").remove();
				$('#feeType\\.id').append($("<option></option>"));
				var feeTypeCategoryId = $("#feeTypeCategory\\.id");
				if(feeTypeCategoryId.val() == null) 
					return;
				var request = $.ajax({
					url: '${createLink(controller:"feeList", action:"loadAllFeeType")}',
				  	data: {feeTypeCategoryId:feeTypeCategoryId.val()},
				  	type:"Get",
				  	dataType: 'xml',
				  	cache:false,
				  	success: parseXml
					});
			}

			function parseXml(xml) {
				var category = $(xml).find("category");
				var name = $(category).attr("name");
				var id = $(category).attr("id");
				$(xml).find("type").each(function(index, type){
					var typeName = $(type).attr("typeName");
					var id = $(type).attr("id");
					var category = $(type).attr("category");
					$('#feeType\\.id')
			         .append($("<option></option>")
			         .attr("value",id)
			         .text(typeName));
				});
			}
        </script>
        <title><g:message code="default.create.label" args="[entityName]" /></title>
    </head>
    <body>
        <div class="nav">
            <span class="menuButton"><a class="home" href="${createLink(uri: '/')}"><g:message code="default.home.label"/></a></span>
            <span class="menuButton"><g:link class="list" action="list"><g:message code="default.list.label" args="[entityName]" /></g:link></span>
        </div>
        <div class="body">
            <h1><g:message code="default.create.label" args="[entityName]" /></h1>
            <g:if test="${flash.message}">
            <div class="message">${flash.message}</div>
            </g:if>
            <g:hasErrors bean="${feeListInstance}">
            <div class="errors">
                <g:renderErrors bean="${feeListInstance}" as="list" />
            </div>
            </g:hasErrors>
            <g:form action="save" >
                <div class="dialog">
                    <table>
                        <tbody>
                        
                            <tr class="prop">
                                <td valign="top" class="name">
                                    <label for="feeTime"><g:message code="feeList.feeTime.label" default="Fee Time" /></label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean: feeListInstance, field: 'feeTime', 'errors')}">
                                    <g:datePicker name="feeTime" precision="month" value="${feeListInstance?.feeTime}"  />
                                </td>
                            </tr>
                        
                            <tr class="prop">
                                <td valign="top" class="name">
                                    <label for="feeTypeCategory"><g:message code="feeList.feeTypeCategory.label" default="Fee Type Category" /></label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean: feeListInstance, field: 'feeTypeCategory', 'errors')}">
                                    <g:select name="feeTypeCategory.id" from="${com.surelution.tinyerp.FeeTypeCategory.list()}" noSelection="${['':''] }" optionKey="id" optionValue="name" onchange="loadFeeType()"  />
                                    <g:select name="feeType.id"/>
                                </td>
                            </tr>
                            
                            <tr class="prop">
                                <td valign="top" class="name">
                                    <label for="saleMoney"><g:message code="feeList.saleMoney.label" default="Sale Money" /></label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean: feeListInstance, field: 'saleMoney', 'errors')}">
                                    <g:textField name="saleMoney" value="${fieldValue(bean: feeListInstance, field: 'saleMoney')}" />
                                </td>
                            </tr>
                        
                        </tbody>
                    </table>
                </div>
                <div class="buttons">
                    <span class="button"><g:submitButton name="create" class="save" value="${message(code: 'default.button.create.label', default: 'Create')}" /></span>
                </div>
            </g:form>
        </div>
    </body>
</html>
